package cn.wgd.zmx.advice;

import cn.wgd.zmx.common.exception.OwnException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 统一异常处理,待完善
 */
@ControllerAdvice
public class HandlerExceptionAdvice {

    /**
     * 处理自定义异常
     * @param e
     * @return
     */
    @ExceptionHandler(OwnException.class)
    @ResponseBody
    public Object customHandler(OwnException e){
        e.printStackTrace();
        return null;
    }

    /**
     * 处理其他异常
     * @param e
     * @return
     */
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Object exceptionHandler(Exception e){
        e.printStackTrace();
        return null;
    }
}
